import { Controller } from 'egg';

class PraiseController extends Controller {

    /**
     * 处理点赞（点赞，取消点赞）
     */
    public async dealWithPraise() {
        const { ctx, ctx: { request } } = this;
        try {
            ctx.validate({
                user_id: 'string',
                target_id: 'string',
                operateType: 'type',
                targetType: 'typeThree'
            }, request.body)
        } catch (e) {
            ctx.body = ctx.helper.responseErrorParam(e.errors[0].message);
            return;
        }
        await ctx.service.praiseService.dealWithPraise(request.body);
        ctx.body = ctx.helper.responseSuccess('操作成功');
    }
}
export default PraiseController;